package com.yuhang.demo;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;

import com.go2.shipping.common.encrypt.AES;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;

import com.yuhang.demo.util.PmAutoTest;

public class PmTest {
	 public static String api = "https://apia.gsb68.com";
//	public static String api = "http://apigsb.go2b2b.com/";
//	public static String api = "http://yhwo.free.idcfengye.com";
//	public static String api = "http://192.168.1.11:8080/";
//	public static String api = "http://localhost:8080/app-1b/";
//	public static String api = "http://47.96.99.15:24010/";
//	 public static String api="http://127.0.0.1:8881/";
//	public static String api = "http://116.62.199.18:16610/";
//	public static String api="http://127.0.0.1:8087/";
//	public static String api="http://127.0.0.1:8080/";
//	public static String api = "http://apibf.go2b2b.com/";
//	public static String api="http://192.168.1.11:8080";
// public static String api="http://apifahuo.go2b2b.com/";
//	public static String api = "http://app.go2b2b.com/";
	public static void main(String[] args) {
		try {
//			 String result = PmAutoTest.byOutId();//登录
			// String result = PmAutoTest.DealPay();
			// String result = PmAutoTest.getCustomerById();//

			// String result = PmAutoTest.likeByName();
			// String result = PmAutoTest.selectSupplier();
			// String result = PmAutoTest.byPlatformAndUsername();
			// String result = PmAutoTest.balance();
			// String result = PmAutoTest.pwdAdd();
			// String result = PmAutoTest.pwdEdit();
			// String result = PmAutoTest.userinfo2b();
//			 String result =null;

//			 for(int i=0;i<50;i++) {
//				String result= PmAutoTest.createOrder(); //TODO
//			 }
//			String result = PmAutoTest.getDefaultDfOrderNum(api);
//			String result = PmAutoTest.createDefaultDF(api);
//			String result = PmAutoTest.loadShopOrders(api);
//			String result = PmAutoTest.syncOrders(api);
//			String result = PmAutoTest.shopOrderList();
//			String result = PmAutoTest.viewInfo();
//			String result =PmAutoTest.pmorderlist();
//			 String result = PmAutoTest.orderUpdate();
			// String result = PmAutoTest.getSupplierByDomain();
			// String result = PmAutoTest.loadSupplierInfo();
			// String result = PmAutoTest.offLineDepositApply();
			// String result = PmAutoTest.queryItemByParamsMustUser();
//			 String result = PmAutoTest.queryItemByParams();
//			 String result = PmAutoTest.queryItemByParamsNoWhole();
//			 String result=PmAutoTest.smartPay();
//			 String result = PmAutoTest.loadSingleGsbItem();
//			 String result = PmAutoTest.loadDsOrSupplierInfo();
			// String result = PmAutoTest.calcManyFreight();
			// String result = PmAutoTest.offLineDepositApply();
			// String result = PmAutoTest.offLineDepositUpdate();
			// String result = PmAutoTest.offLineDepositList();
//			 String result = PmAutoTest.topay();
//			String result = PmAutoTest.apptoPay();
//			 String result =PmAutoTest.topayWap();
			// String result = PmAutoTest.checkPayInfo();
//			String result =PmAutoTest.queryItemByParams();
			// String result = PmAutoTest.addPayInfo();

			// String result = PmAutoTest.updatePayInfo();
			// String result = PmAutoTest.alivCodeByOwner();

// 			 String result = PmAutoTest.orderPay();//订单支付
//			String result = PmAutoTest.wapOrderPay();
			//订单完成
//			String result =PmAutoTest.completeOrder();
			 
//			 String result = PmAutoTest.orderPayWap();//WAP支付
			 
//			 String result = PmAutoTest.returnOrder();
//			 
//			 String result = PmAutoTest.updateRefundSign();
			 
//			 String result = PmAutoTest.updateRefundRefuse();
//			 String result = PmAutoTest.refundListvib();
			// String result = PmAutoTest.accountInfo();
			// String result = PmAutoTest.transactionList();
//			 String result = PmAutoTest.transferReceive();
			// String result = PmAutoTest.transferPayList();
//			 String result = PmAutoTest.receiveApply();
//			 String result = PmAutoTest.transferPay();
//			 String result = PmAutoTest.transferPayBatch();
//			 String result = PmAutoTest.withdrawApply();//提现申请
//			 String result = PmAutoTest.getPrdFrozen();
//			 String result = PmAutoTest.withDrawList2B();

			// String result = PmAutoTest.addGifts();
			// String result = PmAutoTest.listGifts();
			// String result = PmAutoTest.getOffPayState();
			// String result = PmAutoTest.updateOffPayState();
			// String result = PmAutoTest.offPaySet();
			// String result = PmAutoTest.offPaySetvCode();
			// String result = PmAutoTest.matchItem();

//			 String result = PmAutoTest.batchOrderlist();

			// String result = PmAutoTest.AppOrderlist();

//			 String result = PmAutoTest.AppviewExpress();
			// String result = PmAutoTest.validTemplates();
			// String result = PmAutoTest.getIndexUrl();
			// String result = PmAutoTest.getElectronicSheetInfo();

			// String result = PmAutoTest.listBranch();
			// String result = PmAutoTest.batchListOrderInfos();
			// String result = PmAutoTest.batchOrderlist();
			// String result = PmAutoTest.postageList();
			// String result = PmAutoTest.checkCanBeCancel();

//			String result = PmAutoTest.createAikuOrder();
//			String result = PmAutoTest.getAikuActivity();
//			String result=PmAutoTest.getActivityNameByOrderId();
			
			
			
			 
//			 String result = PmAutoTest.returnOrder();

//			 String result = PmAutoTest.cancelWaiforsendOrder();
//			 String result = PmAutoTest.getOrderRefundMaps();
//			 String result = PmAutoTest.detailOrder();
//			 String result = PmAutoTest.updateRefundSign();
//			 String result = PmAutoTest.getStoreIndex();
			 
//			 String result = PmAutoTest.getprXeBalance();
			 
//			 String result = PmAutoTest.updateRefundRefuse();
//			String result=PmAutoTest.transactionRelation();
//			String result=PmAutoTest.sellListPlatform();
//			String result=PmAutoTest.updateAppeal();
//			String result=PmAutoTest.stockOutList();
//			String result=PmAutoTest.advanceList();
//			String result=PmAutoTest.appAdvanceList();
//			String result=PmAutoTest.getSalesTake();
//			String result=PmAutoTest.getOrderRefundByOrderIdAndOrderItemId();
//			String result=PmAutoTest.refundDetail();
//			String result=PmAutoTest.getTakeTracByOrderId();
//			String result=PmAutoTest.submitAppeal();
//			String result=PmAutoTest.refundItemList();
//			String result=PmAutoTest.appStockOutList();
//			String result=PmAutoTest.appStoreListNew();
//			String result=PmAutoTest.getTodayStoreIndex();
//			String result=PmAutoTest.appStoreList();
//			String result=PmAutoTest.getRefundingReach();
// 			String result=PmAutoTest.getAppStoreNotice();
//			String result=PmAutoTest.querySkuByColorSize();
//			String result=PmAutoTest.viewExpress();
//			String result=PmAutoTest.getUserByOutId();
			
//			String result=PmAutoTest.getpreBalance();
			
//			String result=PmAutoTest.getTransferLimit();
			
//			String result=PmAutoTest.orderTakePrintCallBack();
//			String result=PmAutoTest.wapLogin();
//			String result=PmAutoTest.getIndex();
			//APP-1B
//			String result=PmAutoTest.loginApp1b();
			String token="2fc53230-5c53-42e3-88d2-2e2d3b175a01";
//			String result=PmAutoTest.option(token);
//			String result=PmAutoTest.index(token);
//			String result=PmAutoTest.taked(token);
//			String result=PmAutoTest.orderStockOut(token);
//			String result=PmAutoTest.querySkuByColorSize();
//			String result=PmAutoTest.querySkuColorSizeByOuterId();
			
//			String result=PmAutoTest.querySkuColorSizeByOuterIdBatch();
			//1b-store
			
//			String result=PmAutoTest.supplierStoreList();
			
//			String result=PmAutoTest.appSupplierStoreList();
			
//			String result=PmAutoTest.orderTakePrintCallBackWap();
//			String result=PmAutoTest.updateStoreOperationBatch();
//			String result=PmAutoTest.sellListPlatform();
//			String result=PmAutoTest.appointList();
//			String result=PmAutoTest.prepareList();
//			String result=PmAutoTest.pmOrderList();
//			String result=PmAutoTest.takeprintQuery();
//			String result=PmAutoTest.getStoreData();
//			String result=PmAutoTest.getStoreDataAll();
//			String result=PmAutoTest.getSupplierAutoStoreSign();
//			String result=PmAutoTest.setSupplierAutoStoreSign();
//			String result=PmAutoTest.updateStoreOperation();
//			String result=PmAutoTest.getAppMsg();
//			String result=PmAutoTest.getStoreTakeTrace();
//			String result=PmAutoTest.pOrderList(); //2b orderList
			
			
			
			
			
			
			//尖货
//			String result = PmAutoTest.getBestProductSku();
//			String result = PmAutoTest.getProductAndSkuByProductIds();
//			String result = PmAutoTest.updateStockNum();
//			String result = PmAutoTest.getProductDetails();
//			String result = PmAutoTest.updateNextDayStock();
//			String result = PmAutoTest.bestStockList();
//			String result = PmAutoTest.bestStockListByUserId();
//			String result = PmAutoTest.bestDayStockList();
//			String result=PmAutoTest.getSendoutOrderTakeData();
//			String result=PmAutoTest.getCompensateRecord();
//			String result=PmAutoTest.getCompensateNumBySupplierIds();
//			String result=PmAutoTest.updateBestState();
//			String result=PmAutoTest.updateBestStateByUserId();
//			String result=PmAutoTest.returnMargin();
//			String result=PmAutoTest.getSendoutReturnRecord();
//			String result=PmAutoTest.getHasGoodsDay();
//			String result=PmAutoTest.marginReplenish();
//			String result =PmAutoTest.getSupplierDeliverTag();
//			String result=PmAutoTest.getBestProductStatis();
//			String result=PmAutoTest.marginQuery();
//			String result=PmAutoTest.getDiffPrice();
//			String result=PmAutoTest.getDiffData();
//			String result=PmAutoTest.transactionRelation();
//			String result =PmAutoTest.vertifySurfaceItemMatch();
			
//			String result =PmAutoTest.vertifySurfaceItemMatch();
//			String result =PmAutoTest.wintakelogin();
//			String result =PmAutoTest.getBroadcastMsg();
			
//			String result =PmAutoTest.getRecvInfo();
//			String result =PmAutoTest.wintakelogout();
			
//			String result =PmAutoTest.orderRefund();
			
//			String result =PmAutoTest.dataChargePay();
//			String result = PmAutoTest.appearCertifyPay();
//			String result = PmAutoTest.appearCertifyPay();
//			String result = PmAutoTest.certifyRefund();
//			String result = PmAutoTest.certifyCompleted();
//			String result = PmAutoTest.activityPay();
			//退件扫码入库
//			String result = PmAutoTest.getRefundOrderByExpress();
//			String result = PmAutoTest.addWorkSignIn();
//			String result = PmAutoTest.refundScanList();
//			String result = PmAutoTest.refundDealList();
//			String result = PmAutoTest.getRefundItemByExpress();
//			String result = PmAutoTest.getSywRefundItemByExpress();
//			String result = PmAutoTest.getSywRefundItemByTakeCode();
//			String result = PmAutoTest.getRefundItemByTakeCode();
//			String result = PmAutoTest.updateRefundScanTk();
//			String result = PmAutoTest.assignRefundScanClerk();
//			String result = PmAutoTest.updateRelationWithRecord();
//			String result = PmAutoTest.modifyRefundScanInfo();
//			String result = PmAutoTest.dictExpress();
//			String result = PmAutoTest.updateWaitSell();
//			String result = PmAutoTest.getPddPrivacyInfo();

            //fast

//            String result = PmAutoTest.setFastRefund();
//			String result = PmAutoTest.getCreateFastInfo();
//			String result = PmAutoTest.getDsRefundServiceInfo();
//			String result = PmAutoTest.getClerkList();
//			String result = PmAutoTest.getExpressList();
//			String result = PmAutoTest.addProductComments();
//			String result = PmAutoTest.queryOrderComments();
			//app-1b
//			String result = PmAutoTest.queryCommentsByOuterId();
//			String result = PmAutoTest.queryCommentsList();
//			String result = PmAutoTest.getProductStatisByIds();
//			String result = PmAutoTest.sufaceItem();
//			String result = PmAutoTest.orderUpdate();
//			String result = PmAutoTest.loadInteractiveMsgSyn();
//			String result = PmAutoTest.loadCloudOrderMsg();
//			String result = PmAutoTest.valiProductCanExit();
//			String result = PmAutoTest.openUserVip();
//			String result = PmAutoTest.vipAndPackPay();
//			String result = PmAutoTest.getUserSupplierStatis();
//			String result = PmAutoTest.updateCloudVipRate();
//			String result = PmAutoTest.getDiscountVipListBackstage();
//			String result = PmAutoTest.updateAlipay();
//			String result = PmAutoTest.getDiscountVipListByUserId();
//			String result = PmAutoTest.surfaceItemList();
//			String result = PmAutoTest.getDiscountVipAmount();

//			String result = PmAutoTest.careCreateOrderAndPay();

//			String result = PmAutoTest.expressPostageList();



//			String result = PmAutoTest.getRefundItemByExpress();
//			String result = PmAutoTest.getRefundItemByTakeCode();
			//3e退扫码
//			String result = PmAutoTest.dictExpressSyw();
//			String result = PmAutoTest.getSywRefundItemByExpress();

//			String result = PmAutoTest.getSywRefundItemByTakeCode();
//			String result = PmAutoTest.addSywWorkSignIn();
//			String result = PmAutoTest.sywgetExpressList();
//			String result = PmAutoTest.sywgetClerkList();
//			String result = PmAutoTest.sywgetPrintList();
//			String result = PmAutoTest.assignRefundScanRefundClerk();

//			String result = PmAutoTest.getFastRefundOrderNum();
//			String result = PmAutoTest.getRefundScanById();
//			String result =PmAutoTest.sywmodifyRefundScanInfo();
//			String result =PmAutoTest.updateQuestionRefundScan();
//			String result =PmAutoTest.sywrefundScanList();

//			String result = PmAutoTest.loadTakeRefundPayByDsId();
//			String result = PmAutoTest.loadTakeRefundPayBySupplierId();
//			String result = PmAutoTest.relation();
//			String result = PmAutoTest.updateRefundScanInfo();
//			String result = PmAutoTest.getFastTag();
//			String result=PmAutoTest.updateFastTag();
			//app-1b
//			String result =PmAutoTest.loadTakeRefundPay();
//			String result =PmAutoTest.initWhiteBar();
//			String result=PmAutoTest.loadAccountById();
//			String result =PmAutoTest.compdlexPay();
//			String result =PmAutoTest.complexRefund();
//			String result =PmAutoTest.loadAllClerk();
//			String result =PmAutoTest.getWhiteBarBySupplierIds();
//			String result =PmAutoTest.syncShop();
//			String result =PmAutoTest.getWaybillNo(api);
//			String result =PmAutoTest.getLatterPayTag(api);
//            String result =PmAutoTest.getLatterMsg();
//			String result =PmAutoTest.checkPassword();
//			String result =PmAutoTest.getAppAesKey();
//			String result =PmAutoTest.updateLatterPayTag(api);


//			String result = PmAutoTest.refundLatterOrder();
//			String result = PmAutoTest.lattPayAdvance();
//			String result = PmAutoTest.getLattPayAdvanceInfo();



			//sysmgt
//			String result =PmAutoTest.signInLogin();
//			String result =PmAutoTest.logout();
//			System.out.println(result);
//			upload2( );
//			String result=PmAutoTest.getSywItemInfoByExpressNo();
//			uploadCustomV2();
//			uploadVideoV5();

//			String result=PmAutoTest.postageAdd();
//			String result=PmAutoTest.postageUpdate();

//			String result=PmAutoTest.setDefaultByExpressId();

//			String result=PmAutoTest.postageQuery();
//			String result=PmAutoTest.delBatch();
//			String result=PmAutoTest.chargeEdit();
//			String result = PmAutoTest.calcFreightWhole();
//             String result = PmAutoTest.updateRefundScanInfoPuyuan();
//			String result = PmAutoTest.	queryItemByParamsPuyuan();

			uploadCustomV2();
//			System.out.println(result);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	static AES aes = new AES("2016.01_go2plus_chengdu_china");
	public static void uploadVideoV5() throws ClientProtocolException, IOException{
		CloseableHttpClient httpClient = HttpClientBuilder.create().build();
		CloseableHttpResponse httpResponse = null;
		RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(200000).setSocketTimeout(200000000).build();
		HttpPost httpPost = new HttpPost("http://publishtest.ximgs.net:43000/uploadVideoV5");
		httpPost.setConfig(requestConfig);
		httpPost.addHeader("platformId","3e3e");
		MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
		//multipartEntityBuilder.setCharset(Charset.forName("UTF-8"));

		//FileBody bin = new FileBody(file);

		File file = new File("D://1.mp4");

		//multipartEntityBuilder.addBinaryBody("file", file,ContentType.create("image/png"),"abc.pdf");
		//当设置了setSocketTimeout参数后，以下代码上传PDF不能成功，将setSocketTimeout参数去掉后此可以上传成功。上传图片则没有个限制
		multipartEntityBuilder.addBinaryBody("file",file);
		multipartEntityBuilder.addTextBody("userId", aes.encrypt("1"));
		multipartEntityBuilder.addTextBody("platformId",aes.encrypt("3e3e"));
		HttpEntity httpEntity = multipartEntityBuilder.build();
		httpPost.setEntity(httpEntity);

		httpResponse = httpClient.execute(httpPost);
		HttpEntity responseEntity = httpResponse.getEntity();
		int statusCode= httpResponse.getStatusLine().getStatusCode();
		if(statusCode == 200){
			BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
			StringBuffer buffer = new StringBuffer();
			String str = "";
			while( (str = reader.readLine())!=null) {
				buffer.append(str);
			}

			System.out.println(buffer.toString());
		}

		httpClient.close();
		if(httpResponse!=null){
			httpResponse.close();
		}

	}


	public static void uploadCustomV2() throws ClientProtocolException, IOException{
		CloseableHttpClient httpClient = HttpClientBuilder.create().build();
		CloseableHttpResponse httpResponse = null;
		RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(200000).setSocketTimeout(200000000).build();
		HttpPost httpPost = new HttpPost("http://118.112.240.10:43000/uploadCustomV2");
		httpPost.setConfig(requestConfig);

		MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
		//multipartEntityBuilder.setCharset(Charset.forName("UTF-8"));

		//File file = new File("F:\\Ken\\1.PNG");
		//FileBody bin = new FileBody(file);

		File file = new File("D://1.jpg");

		//multipartEntityBuilder.addBinaryBody("file", file,ContentType.create("image/png"),"abc.pdf");
		//当设置了setSocketTimeout参数后，以下代码上传PDF不能成功，将setSocketTimeout参数去掉后此可以上传成功。上传图片则没有个限制
		multipartEntityBuilder.addBinaryBody("file",file);
		multipartEntityBuilder.addTextBody("userId", aes.encrypt("1"));
		System.out.println(aes.decrypt("3343b5dcac0e251c983d7f02ff079bd4"));
		multipartEntityBuilder.addTextBody("platformId",aes.encrypt("e3hw"));
		multipartEntityBuilder.addTextBody("path",aes.encrypt("cloth"));
		HttpEntity httpEntity = multipartEntityBuilder.build();
		httpPost.setEntity(httpEntity);

		httpResponse = httpClient.execute(httpPost);
		HttpEntity responseEntity = httpResponse.getEntity();
		int statusCode= httpResponse.getStatusLine().getStatusCode();
		if(statusCode == 200){
			BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
			StringBuffer buffer = new StringBuffer();
			String str = "";
			while( (str = reader.readLine())!=null) {
				buffer.append(str);
			}

			System.out.println(buffer.toString());
		}
		System.out.println(httpResponse.getStatusLine());

		httpClient.close();
		if(httpResponse!=null){
			httpResponse.close();
		}

	}

	public static void upload2() throws ClientProtocolException, IOException{
	    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
	    CloseableHttpResponse httpResponse = null;
	    RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(200000).setSocketTimeout(200000000).build();
	    HttpPost httpPost = new HttpPost("http://localhost:8080/upload/uploadVideo");
	    httpPost.setConfig(requestConfig);
	    httpPost.addHeader("token","AeVDMFA0b1wJ38KkIrHq0+Q7MLxlmP+ZWP49HTU3GwGG7JP8XD7lLNoUdVNlnLI/");
	    MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
	    //multipartEntityBuilder.setCharset(Charset.forName("UTF-8"));
	         
	    //File file = new File("F:\\Ken\\1.PNG");
	    //FileBody bin = new FileBody(file); 
	         
	    File file = new File("D://22.mp4");
	          
	    //multipartEntityBuilder.addBinaryBody("file", file,ContentType.create("image/png"),"abc.pdf");
	    //当设置了setSocketTimeout参数后，以下代码上传PDF不能成功，将setSocketTimeout参数去掉后此可以上传成功。上传图片则没有个限制
		multipartEntityBuilder.addBinaryBody("file",file);
		multipartEntityBuilder.addTextBody("type", "other");
	    HttpEntity httpEntity = multipartEntityBuilder.build();
	    httpPost.setEntity(httpEntity);
	         
	    httpResponse = httpClient.execute(httpPost);
	    HttpEntity responseEntity = httpResponse.getEntity();
	    int statusCode= httpResponse.getStatusLine().getStatusCode();
	    if(statusCode == 200){
	        BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
	        StringBuffer buffer = new StringBuffer();
	        String str = "";
	        while( (str = reader.readLine())!=null) {
	            buffer.append(str);
	        }
	             
	        System.out.println(buffer.toString());
	    }
	         
	    httpClient.close();
	    if(httpResponse!=null){
	        httpResponse.close();
	    }
	     
	}

}
